﻿namespace UnitTests
{
  public class LogMessage
  {
    private readonly string _message;
    private readonly LoggableObject[] _args;
    private readonly object[] _aliases;

    public LogMessage(string message, params LoggableObject[] args)
    {
      _message = message;
      _args = args;
      _aliases = new object[_args.Length];
      for (int i = 0; i < _args.Length; i++)
        _aliases[i] = _args[i];
    }

    public string Resolve(IAliasProvider aliasProvider)
    {
      for (int i = 0; i < _args.Length; i++)
        if (!(_aliases[i] is string))
          if (aliasProvider.GetAlias(_args[i]) != null)
            _aliases[i] = aliasProvider.GetAlias(_args[i]);

      return ToString();
    }

    public override string ToString()
    {
      return string.Format(_message, _aliases);
    }
  }
}